﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ins = LEET.StandardModuals.Instructions;
using LEET.CommonInterfaces.TestControls;
using System.Windows.Automation;
using LEET.LEETCommon.WidgetLookup;
using Compiled_Tests;

namespace LEET.StandardModuals.Instructions.Actions
{
    public class Resize : Ins.Action
    {
        double width;
        double height;

        public Resize(String[] args)
            : base(args)
        {
            width = double.Parse(args[3].Trim());
            height = double.Parse(args[4].Trim());
        }

        public static IAutomationActionResult StaticCall(IBox box, String element, int x, int y)
        {
            AutomationElement e = WidgetFinder.Find(element, box.RootElement);
            Object obj;
            e.TryGetCurrentPattern(TransformPattern.Pattern, out obj);
            TransformPattern pattern = obj as TransformPattern;
            if (pattern != null)
                pattern.Resize(x, y);
            return new AutomationActionResult();
        }

        public override String RenderStaticCall()
        {
            return "LEET.StandardModuals.Instructions.Actions.Resize.StaticCall(Box, \"" + element + "\", " + width + ", " + height + ")";
        }

        public override string PlainText()
        {
            return "Window resized to width (x) = " + width + ", and height (y) = " + height;
        }
    }
}
